#include <repository/system/role_repository.h>

using namespace model;

// CRUD Operations
insert_ret_type RoleRepository::create(const RoleDTO& role_dto)
{
  return _insert(role_dto);
};

select_ret_type<RoleDTO> RoleRepository::get(const std::string& role_name)
{
  return _select(db::role{}.role_name == role_name);
};

update_ret_type RoleRepository::updateById(const in_id_type id,
                                           const RoleDTO& dto)
{
  return _update(dto, db::role{}.id == dto.id);
};

delete_ret_type RoleRepository::removeById(const in_id_type id)
{
  return _remove(db::role{}.id == id);
}

// Custom Queries
select_ret_type<RoleDTO> RoleRepository::getAll()
{
  return _select(db::role{}.id >= 0);
}

select_ret_type<RoleDTO> RoleRepository::getByPage(int page_size, int offset)
{
  return _select_from(db::role{}.id >= 0, page_size, offset);
}

count_type RoleRepository::count()
{
  return _countById();
}

// 其他方法实现...
